<%@ page language="java" errorPage="/framework/jsp/error.jsp"
	pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@page
	import="com.xwtech.cring.pub.po.SysUserInfo,
	        com.xwtech.framework.pub.po.FrameLogin,
	        com.xwtech.framework.login.pub.AbstractLoginToken,
	        com.xwtech.framework.pub.utils.SessionUtils,
	        com.xwtech.framework.pub.web.SessionNameConstants,
	       com.xwtech.cring.admin.bo.BgUserBO,
	        com.xwtech.cring.pub.po.SysUserInfo"%>

<%@ include file="/framework/jsp/taglibs.jsp"%>
<%@ include file="/cring/jsp/admin/header.jsp"%>
<%@ include file="/cring/jsp/admin/menu.jsp"%>
<script>
/*** 检查是否由数字字母组成 ***/
function chkpassword(text)
{
	if(text.length < 8)
		return false;

	var c, num = 0, alpha = 0, other = 0;
	for(var i=0;i<text.length;i++)
	{
		c = text.charAt(i);
		if(c >= '0' && c <= '9')
			num ++;
		else if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
			alpha ++;
		else
			other ++;
	}

	if(num == 0 || alpha == 0)
	{
		return false;
	}
	if(other > 0)
	{
		return false;
	}

	return true;
}

	function check(){
		var loginPwdOld=modifyUserForm.loginPwdOld.value;
		var loginPwdNew1=modifyUserForm.loginPwdNew1.value;
		var loginPwdNew2=modifyUserForm.loginPwdNew2.value;
		   if(loginPwdOld==""){
                alert("请输入原密码!");
                modifyUserForm.loginPwdOld.focus();
                return false;
            }
               if(loginPwdNew1==""){
                alert("请输入新密码!");
                modifyUserForm.loginPwdNew1.focus();
                return false;
            }
               if(loginPwdNew2==""){
                alert("请输入确认新密码!");
                modifyUserForm.loginPwdNew2.focus();
                return false;
            }
         
           if(!chkpassword(loginPwdNew1)||loginPwdNew1.length<8||loginPwdNew1.length>16){
                alert("密码为至少为8位或者小于16位的数字、英文字母组合!");
                modifyUserForm.loginPwdNew1.focus();
                return false;
            }
          if(loginPwdNew2!=loginPwdNew1){
               alert("两次输入的密码不相同!");
               modifyUserForm.loginPwdNew2.focus();
               return false;
         }
		return true;
	}
</script>
<%
	AbstractLoginToken loginToken = (AbstractLoginToken)
      SessionUtils.getObjectAttribute(session,SessionNameConstants.LOGIN_TOKEN);
      String loginName=loginToken.getFrameLogin().getLoginName();
      BgUserBO bgUserBO=new BgUserBO();
      SysUserInfo userinfo=(SysUserInfo)bgUserBO.getBgUserByLoginname(loginName);
      Integer userInfoId=userinfo.getUserInfoId();
%>
<form name="modifyUserForm"
	action="/cring/jsp/admin/bgUserModifyPwd.do?method=updateBgUser"
	onSubmit="return check();" method="post" enctype="multipart/form-data">
	<input type="hidden" name="user_info_id" value="<%=userInfoId%>">
	<input type="hidden" name="login_name" value="<%=loginName%>">
	<input type="hidden" name="user_name" value="<%=userinfo.getUserName() %>">
	<input type="hidden" name="_url"
		value="/cring/jsp/admin/main.jsp">
	<input type="hidden" name="_query"
		value="/admin/bgUserFrameLogin_update.xml,/admin/bgUserInfo_update.xml">
	<table width="100%" border="0" align="center" cellpadding="0"
		cellspacing="0" class="table_big">
		<tr>
			<td>
				<table width="100%" border="0" align="center" cellpadding="0"
					cellspacing="0">
					<tr>
						<td width="4" height="4">
							<img src="/cring/image/admin/title_r4_c3.gif" width="4"
								height="4">
						</td>
						<td height="4">
							<img src="/cring/image/admin/title_r4_c4.jpg" width="100%"
								height="4">
						</td>
						<td width="4" height="4">
							<img src="/cring/image/admin/title_r4_c8.gif" width="4"
								height="4">
						</td>
					</tr>
				</table>
				<table width="100%" border="0" align="center" cellpadding="0"
					cellspacing="0">
					<tr>


						<td width="4" background="/cring/image/admin/title_r5_c3.jpg"
							bgcolor="#CCCCCC">
							&nbsp;
						</td>
						<td bgcolor="#EEF7FD">
							<table width="98%" border="0" align="center" cellpadding="0"
								cellspacing="4">
								<tr>
									<td width="24" align="center">
										<img src="/cring/image/admin/title_r6_c5.gif" width="24"
											height="24">
									</td>
									<td class="font_title_normal">
										用户密码修改
									</td>
								</tr>
							</table>
							<table width="98%" border="0" align="center" cellpadding="0"
								cellspacing="0">
								<tr>
									<td height="12" valign="top">
										<table width="100%" border="0" align="center" cellpadding="0"
											cellspacing="1">
											<tr>
												<td height="5"
													background="/cring/image/admin/title_r10_c5.jpg"></td>
											</tr>
										</table>
									</td>
								</tr>
							</table>
							<table width="97%" border="0" cellpadding="0" cellspacing="1"
								class="table_normal">
								<tr>
									<td valign="middle" class="td_item_right">
										用户名:
									</td>
									<td class="td_normal_left"><%=loginName == null ? "" :loginName %>
									</td>
								</tr>
								<tr>
									<td valign="middle" class="td_item_right">
										姓名:
									</td>
									<td class="td_normal_left"><%=userinfo.getUserName() == null ? "" : userinfo
					.getUserName()%>
									</td>
								</tr>

								<tr>
									<td valign="middle" class="td_item_right" width="150">
										原密码:
									</td>
									<td class="td_normal_left">
										<input type="password" name="loginPwdOld" size=16 maxlength=16
											class="input_normal_nowidth">
										<font color="red">*</font>(原密码不能为空)
									</td>
								</tr>
								<tr>
									<td valign="middle" class="td_item_right">
										新密码:
									</td>
									<td class="td_normal_left">
										<input type="password" name="loginPwdNew1" size=16
											maxlength=16 class="input_normal_nowidth" />
											<font color="red">*</font>(新密码不能为空)
									</td>
								</tr>
								<tr>
									<td valign="middle" class="td_item_right">
										确认新密码:
									</td>
									<td class="td_normal_left">
										<input type="password" name="loginPwdNew2" size=16
											maxlength=16 class="input_normal_nowidth" />
											<font color="red">*</font>(注：确认新密码必须与新密码一致)
									</td>
								</tr>
							</table>
							<br>
							<table border="0" align="center" cellpadding="0" cellspacing="20">
								<tr>
									<td>
										<div align="center">
											<input type="submit" class="button_xy_normal" id="clear2222"
												value="保 存">
										</div>
									</td>
									&nbsp;
									<td align="center" class="button_xy_normal" onclick="self.history.go(-1)">返 回</td>
								</tr>
							</table>
						</td>
						<td width="4" background="/cring/image/admin/title_r5_c9.jpg"
							bgcolor="#CCCCCC">
							&nbsp;
						</td>
					</tr>
				</table>
				<table width="100%" border="0" align="center" cellpadding="0"
					cellspacing="0">
					<tr>
						<td width="4" height="4">
							<img src="/cring/image/admin/title_r10_c3.gif" width="4"
								height="4">
						</td>
						<td height="4">
							<img src="/cring/image/admin/title_r12_c4.jpg" width="100%"
								height="4">
						</td>
						<td width="4" height="4">
							<img src="/cring/image/admin/title_r10_c8.gif" width="4"
								height="4">
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</form>
<%@ include file="/cring/jsp/admin/footer.jsp"%>